enyo.kind({
    name: "MyApps.GolfPlusApp",
    kind: enyo.VFlexBox,
    components: [{
        name: "slidingPane",
        kind: "SlidingPane",
        flex: 1,
        components: [{
            name: "left",
            flex: 1,
            kind: "SlidingView",
            components: [{
                kind: "Scroller",
                flex: 1,
                className: "menu",
                components: [{
                    name: "pane0",
                    kind: "Pane",
                    flex: 1,
                    transitionKind: "enyo.transitions.LeftRightFlyin",
                    components: [{
                        kind: "VFlexBox",
                        components: [{
                            kind: "Item",
                            tapHighlight: true,
                            onclick: "showNews",
                            components: [{
                                kind: "HFlexBox",
                                
                                components: [{
                                    kind: "Image",
                                    src: "images/buttons/NewsIcon.png",
                                    className: "menuicon"
                                }, {
                                    name: "newsLabel",
                                    content: "News",
                                }, ]
                            }]
                        }, {
                        
                            kind: "Item",
                            tapHighlight: true,
                            onclick: "expandguide",
                            components: [{
                                kind: "HFlexBox",
                                components: [{
                                    kind: "Image",
                                    src: "images/buttons/GuidesIcon.png",
                                    className: "menuicon"
                                }, {
                                    content: "Guide des Golfs"
                                }]
                            }]
                        
                        
                        }, {
                            name: "guideitem",
                            kind: "Drawer",
                            open: false,
                            components: [{
                                kind: "Item",
                                tapHighlight: true,
                                content: "Tous les Golfs",
                                onclick: "showGolfClubs",
                                className: "submenu",
                            }, {
                                kind: "Item",
                                tapHighlight: true,
                                content: "Golfs à proximité",
                                onclick: "showGolfClubsAround",
                                className: "submenu",
                            }, {
                                kind: "Item",
                                tapHighlight: true,
                                content: "Les Pros",
                                onclick: "showPartners",
                                className: "submenu",
                            }, ]
                        }, {
                            kind: "Item",
                            tapHighlight: true,
                            onclick: "expandgolfplus",
                            components: [{
                                kind: "HFlexBox",
                                components: [{
                                    kind: "Image",
                                    src: "images/buttons/GolfPlusIcon.png",
                                    className: "menuicon"
                                }, {
                                    content: "Golf Plus",
                                }]
                            }]
                        
                        
                        }, {
                            name: "golfplusitem",
                            kind: "Drawer",
                            caption: "",
                            open: false,
                            components: [{
                                kind: "Item",
                                tapHighlight: true,
                                content: "Nos magasins",
                                onclick: "showStores",
                                className: "submenu",
                            },                            /*
                             {
                             kind: "Item",
                             tapHighlight: true,
                             content: "Les services + Golf Plus",
                             className: "submenu",
                             onclick: "expandservices",
                             
                             },
                             
                             {
                             name: "servicesitem",
                             kind: "Drawer",
                             open: false,
                             
                             components: [{
                             kind: "Item",
                             tapHighlight: true,
                             content: "Contrat prix",
                             onclick: "",
                             className: "subsubmenu",
                             }, {
                             kind: "Item",
                             tapHighlight: true,
                             content: "Contrat 21 jours",
                             onclick: "showcontract21days",
                             className: "subsubmenu",
                             }, {
                             kind: "Item",
                             tapHighlight: true,
                             content: "Contrat reprise",
                             onclick: "",
                             className: "subsubmenu",
                             }, ]
                             
                             }, */
                            {
                                kind: "Item",
                                tapHighlight: true,
                                content: "Journées démo",
                                onclick: "showDemoDays",
                                className: "submenu",
                            }, {
                                kind: "Item",
                                tapHighlight: true,
                                content: "Newsletter",
                                onclick: "showNewsletter",
                                className: "submenu",
                            }, {
                                kind: "Item",
                                tapHighlight: true,
                                content: "Golf Plus sur Facebook",
                                onclick: "showFacebookWeb",
                                className: "submenu",
                            }, {
                                kind: "Item",
                                tapHighlight: true,
                                content: "Autre",
                                onclick: "showAbout",
                                className: "submenu",
                            }, ]
                        }, {
                            kind: "Item",
                            tapHighlight: true,
                            onclick: "expandboutique",
                            
                            components: [{
                                kind: "HFlexBox",
                                components: [{
                                    kind: "Image",
                                    src: "images/buttons/PromoIcon.png",
                                    className: "menuicon"
                                }, {
                                    content: "Boutique",
                                }]
                            }]
                        
                        
                        }, {
                            name: "boutiqueitem",
                            kind: "Drawer",
                            open: false,
                            components: [{
                                kind: "Item",
                                tapHighlight: true,
                                content: "La promo de la semaine",
                                onclick: "showWeekPromotion",
                                className: "submenu",
                            }, {
                                kind: "Item",
                                tapHighlight: true,
                                content: "Les bonnes affaires",
                                onclick: "showProductsList",
                                className: "submenu",
                            }, ]
                        }, {
                            kind: "Item",
                            tapHighlight: true,
                            onclick: "showGolfPlusTv",
                            components: [{
                                kind: "HFlexBox",
                                components: [{
                                    kind: "Image",
                                    src: "images/buttons/VideosIcon.png",
                                    className: "menuicon"
                                }, {
                                    content: "Golf Plus TV",
                                }]
                            }]
                        
                        
                        }, ],
                    }, ]
                }, ]
            }, //			 {
            //                kind: "VFlexBox",
            //                align: "center",
            //                pack: "center",
            //                className: "menu",
            //                components: [{
            //                    kind: "Image",
            //                    src: "images/gp.png",
            //                }
            //				]
            //            },
            
            ]
        }, {
            name: "middle",
            flex: 3,
            kind: "SlidingView",
            peekWidth: 50,
            components: [{
                name: "pane",
                kind: "Pane",
                flex: 1,
                components: [{
                    kind: "VFlexBox",
                    align: "center",
                    pack: "center",
                    className: "menu",
                    components: [{
                        kind: "Image",
                        src: "images/gp.png",
                    }]
                }, {
                    name: "news",
                    className: "enyo-bg",
                    kind: "MyApps.News",
                    onBack: "goBack",
                    onUnreadCount: "updateUnreadCount"
                }, {
                    name: "boutique",
                    className: "enyo-bg",
                    kind: "MyApps.Boutique",
                    lazy: true,
                    onBack: "goBack"
                }, {
                    name: "golfplustv",
                    className: "enyo-bg",
                    kind: "MyApps.GolfPlusTv",
                    lazy: true,
                    onBack: "goBack"
                },                /**
                 * golfguide
                 */
                {
                    name: "golfclubs",
                    className: "enyo-bg",
                    kind: "MyApps.GolfClubs",
                    onBack: "goBack",
                    lazy: true
                }, {
                    name: "golfclubsaround",
                    className: "enyo-bg",
                    kind: "MyApps.GolfClubsAround",
                    onBack: "goBack",
                    lazy: true
                }, {
                    name: "partners",
                    className: "enyo-bg",
                    kind: "MyApps.Partners",
                    onBack: "goBack",
                    lazy: true
                },                /**
                 * golf plus
                 */
                {
                    name: "stores",
                    kind: "MyApps.Stores",
                    onBack: "goBack",
                    lazy: true
                }, {
                    name: "advantages",
                    kind: "MyApps.Advantages",
                    onBack: "goBack",
                    lazy: true
                }, {
                    name: "demodays",
                    kind: "MyApps.DemoDays",
                    onBack: "goBack",
                    lazy: true
                }, {
                    name: "newsletter",
                    kind: "MyApps.Newsletter",
                    onBack: "goBack",
                    lazy: true
                }, {
                    name: "facebookweb",
                    kind: "MyApps.Web",
                    onBack: "goBack",
                    lazy: true
                }, {
                    name: "about",
                    kind: "MyApps.About",
                    onBack: "goBack",
                    lazy: true
                },                /**
                 * Boutique
                 */
                {
                    name: "weekPromotion",
                    kind: "MyApps.WeekPromotion",
                    onBack: "goBack",
                    lazy: true
                }, {
                    name: "productsList",
                    kind: "MyApps.ProductsList",
                    onBack: "goBack",
                    lazy: true
                },                /**
                 * Advantages
                 */
                {
                    name: "contract21days",
                    kind: "MyApps.Contract21Days",
                    lazy: true,
                    onBack: "goBack",
                }]
            }, {
                kind: "Toolbar",
                components: [{
                    kind: "GrabButton"
                }]
            }]
        }, ]
    
    }, ],
    showNews: function(){
        this.$.pane.selectViewByName("news");
    },
    /**
     * update unread news count label
     */
    updateUnreadCount: function(inSender, unreadcount){
        if (unreadcount > 0) {
            this.$.newsLabel.setContent("News (" + unreadcount + ")");
        }
        else {
            this.$.newsLabel.setContent("News");
        }
    },
    
    
    
    
    showBoutique: function(){
        this.$.pane.selectViewByName("boutique");
    },
    showGolfPlusTv: function(){
        this.$.pane.selectViewByName("golfplustv");
    },
    
    feedSelected: function(inSender, inFeed){
        this.$.pane.selectViewByName("detail");
        this.$.detail.setUrl(inFeed.link);
    },
    linkClicked: function(inSender, inUrl){
        this.$.detail.setUrl(inUrl);
        this.$.pane.selectViewByName("detail");
    },
    goBack: function(inSender, inEvent){
        this.$.pane.back(inEvent);
    },
    
    /**
     * golf guides
     */
    showGolfClubs: function(){
        this.$.pane.selectViewByName("golfclubs");
    },
    showGolfClubsAround: function(){
        this.$.pane.selectViewByName("golfclubsaround");
    },
    showPartners: function(){
        this.$.pane.selectViewByName("partners");
    },
    /**
     * golf plus
     */
    showStores: function(){
        this.$.pane.selectViewByName("stores");
    },
    showAdvantages: function(){
        this.$.pane.selectViewByName("advantages");
    },
    showDemoDays: function(){
        this.$.pane.selectViewByName("demodays");
    },
    showNewsletter: function(){
        this.$.pane.selectViewByName("newsletter");
    },
    showFacebookWeb: function(){
        this.$.pane.selectViewByName("facebookweb");
        this.$.facebookweb.setUrl("http://www.facebook.com/pages/GOLF-PLUS-wwwgolfplusfr/202051404335");
    },
    showAbout: function(){
        this.$.pane.selectViewByName("about");
    },
    /**
     * Boutique
     */
    showProductsList: function(){
        this.$.pane.selectViewByName("productsList");
    },
    showWeekPromotion: function(){
        this.$.pane.selectViewByName("weekPromotion");
    },
    /**
     * Advantages
     */
    showcontract21days: function(){
        this.$.pane.selectViewByName("contract21days");
    },
    
    expandguide: function(){
        this.$.guideitem.setOpen(!this.$.guideitem.open);
    },
    expandgolfplus: function(){
        this.$.golfplusitem.setOpen(!this.$.golfplusitem.open);
    },
    expandservices: function(){
        this.$.servicesitem.setOpen(!this.$.servicesitem.open);
        
    },
    expandboutique: function(){
        this.$.boutiqueitem.setOpen(!this.$.boutiqueitem.open);
        this.showBoutique();
    }
});

